
/*
 * Copyright 2002-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2019原作者。
 *
 *根据Apache许可证2.0版（“许可证”）许可；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，否则软件
 *根据许可证分发是在“按原样”的基础上分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证
 *许可证下的限制。
 */

package org.springframework.context;

/**
 * Interface that encapsulates event publication functionality.
 *
 * <p>Serves as a super-interface for {@link ApplicationContext}.
 *
 * @author Juergen Hoeller
 * @author Stephane Nicoll
 * @since 1.1.1
 * @see ApplicationContext
 * @see ApplicationEventPublisherAware
 * @see org.springframework.context.ApplicationEvent
 * @see org.springframework.context.event.ApplicationEventMulticaster
 * @see org.springframework.context.event.EventPublicationInterceptor
 */
/**
 *用于封装事件发布功能的接口。
 *
 *<p>作为｛@link ApplicationContext｝的超级接口。
 *
 *@作者Juergen Hoeller
 *@作者Stephane Nicoll
 *@自1.1.1起
 *@请参阅ApplicationContext
 *@请参阅ApplicationEventPublisherware
 *@参见org.springframework.context.ApplicationEvent
 *@参见org.springframework.context.event.ApplicationEventMultimaster
 *@参见org.springframework.context.event.EventPublicationInterceptor
 */
@FunctionalInterface
public interface ApplicationEventPublisher {

	/**
	 * Notify all <strong>matching</strong> listeners registered with this
	 * application of an application event. Events may be framework events
	 * (such as ContextRefreshedEvent) or application-specific events.
	 * <p>Such an event publication step is effectively a hand-off to the
	 * multicaster and does not imply synchronous/asynchronous execution
	 * or even immediate execution at all. Event listeners are encouraged
	 * to be as efficient as possible, individually using asynchronous
	 * execution for longer-running and potentially blocking operations.
	 * @param event the event to publish
	 * @see #publishEvent(Object)
	 * @see org.springframework.context.event.ContextRefreshedEvent
	 * @see org.springframework.context.event.ContextClosedEvent
	 */
	/**
	 *通知所有注册的<strong>匹配</strong>侦听器
	 *应用程序事件的应用程序。事件可能是框架事件
	 *（如ContextRefreshedEvent）或特定于应用程序的事件。
	 *<p>这样的事件发布步骤实际上是向
	 *multicaster，并不意味着同步/异步执行
	 *甚至立即执行。鼓励活动听众
	 *为了尽可能高效，单独使用异步
	 *执行更长时间的运行和潜在的阻塞操作。
	 *@param event要发布的事件
	 *@see#publishEvent（对象）
	 *@参见org.springframework.context.event.ContextRefreshedEvent
	 *@参见org.springframework.context.event.ContextClosedEvent
	 */
	default void publishEvent(ApplicationEvent event) {
		publishEvent((Object) event);
	}

	/**
	 * Notify all <strong>matching</strong> listeners registered with this
	 * application of an event.
	 * <p>If the specified {@code event} is not an {@link ApplicationEvent},
	 * it is wrapped in a {@link PayloadApplicationEvent}.
	 * <p>Such an event publication step is effectively a hand-off to the
	 * multicaster and does not imply synchronous/asynchronous execution
	 * or even immediate execution at all. Event listeners are encouraged
	 * to be as efficient as possible, individually using asynchronous
	 * execution for longer-running and potentially blocking operations.
	 * @param event the event to publish
	 * @since 4.2
	 * @see #publishEvent(ApplicationEvent)
	 * @see PayloadApplicationEvent
	 */
	/**
	 *通知所有注册的<strong>匹配</strong>侦听器
	 *事件的应用程序。
	 *<p>如果指定的{@code事件}不是{@link ApplicationEvent}，
	 *它被封装在{@link PayloadApplicationEvent}中。
	 *<p>这样的事件发布步骤实际上是向
	 *multicaster，并不意味着同步/异步执行
	 *甚至立即执行。鼓励活动听众
	 *为了尽可能高效，单独使用异步
	 *执行更长时间的运行和潜在的阻塞操作。
	 *@param event要发布的事件
	 *@自4.2起
	 *@参见#publishEvent（ApplicationEvent）
	 *@请参阅PayloadApplicationEvent
	 */
	void publishEvent(Object event);

}
